<template>
  <div class="app-container">
    <el-form ref="form" :model="form" :rules="rules" label-width="120px">
      <el-form-item label="邮箱" prop="email">
        <el-input v-model="form.email" />
      </el-form-item>
      <el-form-item label="手机" prop="phone">
        <el-input v-model="form.phone" />
      </el-form-item>
      <el-form-item label="url" prop="url">
        <el-input v-model="form.url" />
      </el-form-item>
      <el-form-item label="ip" prop="ip">
        <el-input v-model="form.ip" />
      </el-form-item>
      <el-form-item label="MAC" prop="mac">
        <el-input v-model="form.mac" />
      </el-form-item>
      <el-form-item>
        <el-button type="primary" @click="onSubmit">校验</el-button>
      </el-form-item>
    </el-form>
  </div>
</template>

<script>
export default {
  data() {
    return {
      form: {}
    }
  },
  computed: {
    rules() {
      const required = true;
      return {
        email: [{ required, type: 'email', message: '请输入正确的邮箱', trigger: 'blur' }],
        phone: [{ required, type: 'phone', message: '请输入正确的手机号码', trigger: 'blur' }],
        url: [{ required, type: 'url', message: '请输入正确的url', trigger: 'blur' }],
        ip: [{ required, type: 'ip', message: '请输入正确的IP地址', trigger: 'blur' }],
        mac: [{ required, type: 'mac', message: '请输入正确的MAC地址', trigger: 'blur' }]
      }
    }
  },
  methods: {
    onSubmit() {
      this.$refs.form.validate((valid) => {
        if (valid) {
          this.$message.success('submit!')
        }
      })
    }
  }
}
</script>

<style scoped>
.line{
  text-align: center;
}
</style>

